package per.zhen.common.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * 加密工具类
 * @author zhen
 * **/
public class EncryptUtil
{
    /**
     * MD5加密
     * @param data
     * @throws NoSuchAlgorithmException 
     * **/
    public static byte[] MD5(byte[] data) throws NoSuchAlgorithmException
    {
        MessageDigest md5 = MessageDigest.getInstance("MD5");  
        md5.update(data);
        return md5.digest();
    }
    
    public static String MD5(String data) throws NoSuchAlgorithmException
    {
        byte[] bEncryp = MD5(data.getBytes());
        return NumberConvUtil.byteToHex(bEncryp);
    }
}
